package com.liuqing.www.web服务;

import org.codehaus.xfire.XFire;
import org.codehaus.xfire.XFireFactory;
import org.codehaus.xfire.server.http.XFireHttpServer;
import org.codehaus.xfire.service.Service;
import org.codehaus.xfire.service.binding.ObjectServiceFactory;
import org.codehaus.xfire.service.invoker.BeanInvoker;

public class EmbeddedServer
{
	XFireHttpServer server;
	public boolean start()
	{
		ObjectServiceFactory serviceFactory = new ObjectServiceFactory();
		Service service = serviceFactory.create(IHelloService.class);
		service.setInvoker(new BeanInvoker(new HelloServiceImpl()));
		XFire xfire = XFireFactory.newInstance().getXFire();
		service.addInHandler(new ServerAuthenticationHandler());
		xfire.getServiceRegistry().register(service);
		server = new XFireHttpServer();
		server.setPort(8191);
		try
		{
		server.start();
		}
		catch (Exception e)
		{
		return false;
		}
		return true;
	}
	public static void main(String[] args)
	{
		EmbeddedServer server = new EmbeddedServer();
		server.start();
	}
}